package com.zhf.cloud.gateway.springcloudgateway.model.user;

import com.zhf.cloud.gateway.springcloudgateway.entity.Menu;
import com.zhf.cloud.gateway.springcloudgateway.entity.MerchantInfoAndModeuleInfo;
import lombok.Data;

import java.io.Serializable;
import java.util.List;

/**
 * @author: 曾鸿发
 * @create: 2021-11-22 11:55
 * @description：
 **/
@Data
public class Menu4Hsrws implements Serializable {

    private static final long serialVersionUID = 749360940290141180L;

    private Long id;

    private Long modelId;

    private String title;

    private String pageURL;

    private String name;

    private String icon;

    private Integer openType;

    private Boolean extend;

    private List<Menu4Hsrws> child;

    public static Menu4Hsrws convertFromMenu(Menu menu) {

        Menu4Hsrws menu4Hsrws = new Menu4Hsrws();

        menu4Hsrws.setId(menu.getId());
        menu4Hsrws.setTitle(menu.getName());


        menu4Hsrws.setPageURL(menu.getUrl().indexOf("pages/") == 0 ? "sys/" + menu.getUrl() : menu.getUrl());
        menu4Hsrws.setName(menu.getName());
        menu4Hsrws.setIcon(menu.getCss());
        menu4Hsrws.setOpenType(2);
        menu4Hsrws.setExtend(false);

        return menu4Hsrws;
    }

    public static Menu4Hsrws convertFromModel(MerchantInfoAndModeuleInfo merchantInfoAndModeuleInfo) {

        Menu4Hsrws menu4Hsrws = new Menu4Hsrws();

        menu4Hsrws.setId(merchantInfoAndModeuleInfo.getMerchantId());
        menu4Hsrws.setModelId(merchantInfoAndModeuleInfo.getModelId());

        menu4Hsrws.setTitle(merchantInfoAndModeuleInfo.getModelName());
        menu4Hsrws.setIcon("fa-windows");

        menu4Hsrws.setName(merchantInfoAndModeuleInfo.getModelName());
        menu4Hsrws.setOpenType(2);
        menu4Hsrws.setExtend(false);

        return menu4Hsrws;
    }

}
